$(function(){
  $("#updatePassBtn").on("click",function(){
    var newPass = $("#newPassword").val();
    var newPasswordSure = $("#newPasswordSure").val();
    if(newPass.length < 6){
      toastrComponent.show("warning", "密码至少6位！");
      return;
    }
    if(newPass != newPasswordSure){
      toastrComponent.show("warning", "两次密码不一致！");
      return;
    }
    var loginUserId = $("#userId").val();

    $.ajax({
      type : "get",
      url : "updatePass.do",
      data : {
        "userId" : loginUserId,
        "password" : newPass
      },
      success : function(v) {
       if("success" == v){
         toastrComponent.show("success", "修改密码成功!请重新登录!");
         $("#newPassword").val("");
         $("#newPasswordSure").val("");
         setTimeout("window.location.href = 'login.html'",2000);
       }
      }
    });
  });
});


